/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package td3.Vue;

import td3.Modele.*;
/**
 *
 * @author Mohamed Laaqoud
 */
public class FenetreAccueil1 extends javax.swing.JFrame {
    
    /**
     * Constructeur d'une nouvelle FenetreAccueil1
     */
    public FenetreAccueil1() {
        initComponents();
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        
        ButtonTypeJeu = new javax.swing.ButtonGroup();
        ButtonTypeJoueurs = new javax.swing.ButtonGroup();
        jSeparator4 = new javax.swing.JSeparator();
        jSeparator5 = new javax.swing.JSeparator();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        Morpion = new javax.swing.JRadioButton();
        Puissance4 = new javax.swing.JRadioButton();
        IAvsIA = new javax.swing.JRadioButton();
        HumVsIA = new javax.swing.JRadioButton();
        HumVsHum = new javax.swing.JRadioButton();
        Nom1 = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        Nom2 = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jSeparator2 = new javax.swing.JSeparator();
        jSeparator3 = new javax.swing.JSeparator();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        
        jLabel1.setText("Type de jeu");
        
        jLabel2.setText("Type de joueurs");
        
        jButton1.setText("OK");
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton1MouseClicked(evt);
            }
        });
        
        jButton2.setText("Quitter");
        jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton2MouseClicked(evt);
            }
        });
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        
        ButtonTypeJeu.add(Morpion);
        Morpion.setText("Morpion");
        Morpion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MorpionActionPerformed(evt);
            }
        });
        
        ButtonTypeJeu.add(Puissance4);
        Puissance4.setText("Puissance4");
        
        ButtonTypeJoueurs.add(IAvsIA);
        IAvsIA.setText("IA Vs IA");
        
        ButtonTypeJoueurs.add(HumVsIA);
        HumVsIA.setText("Humain Vs. IA");
        HumVsIA.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                HumVsIAActionPerformed(evt);
            }
        });
        
        ButtonTypeJoueurs.add(HumVsHum);
        HumVsHum.setText("Humain Vs. Humain");
        
        jLabel3.setText("Nom du 1er joueur");
        
        jLabel4.setText("Nom du 2eme joueur");
        
        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
        jLabel5.setText("Bienvenue");
        
        jLabel6.setText("Sélectionnez vos paramètres, puis Cliquez \"Jouer\" pour commencer la partie:");
        
        jLabel7.setText("\"Quitter\" pour partir.");
        
        jLabel9.setText(" Copyright © 2012 - 2013, DA SILVA & LAAQOUD");
        
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jLabel2)
                .addGroup(layout.createSequentialGroup()
                .addGap(36, 36, 36)
                .addComponent(jLabel3)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(IAvsIA)
                .addGap(10, 10, 10))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(Nom1, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(jButton1)
                .addGap(18, 18, 18)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                .addGap(2, 2, 2)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                .addComponent(HumVsIA)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(HumVsHum))
                .addGroup(layout.createSequentialGroup()
                .addComponent(jButton2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 51, Short.MAX_VALUE)
                .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 175, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel4)
                .addGap(18, 18, 18)
                .addComponent(Nom2, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
                .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel1)
                .addGap(70, 70, 70)
                .addComponent(Morpion)
                .addGap(18, 18, 18)
                .addComponent(Puissance4)
                .addGap(0, 0, Short.MAX_VALUE))))
                .addComponent(jSeparator1)
                .addComponent(jSeparator2, javax.swing.GroupLayout.Alignment.TRAILING)
                .addComponent(jSeparator3)
                .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel9)
                .addGap(0, 0, Short.MAX_VALUE))
                .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 499, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(layout.createSequentialGroup()
                .addGap(204, 204, 204)
                .addComponent(jLabel5)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                );
        layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel5)
                .addGap(12, 12, 12)
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel1)
                .addComponent(Morpion)
                .addComponent(Puissance4))
                .addGap(11, 11, 11)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel2)
                .addComponent(IAvsIA)
                .addComponent(HumVsIA)
                .addComponent(HumVsHum))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 19, Short.MAX_VALUE)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jLabel3)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(Nom1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(Nom2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jLabel4)))
                .addGap(15, 15, 15)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jButton1)
                .addComponent(jButton2)
                .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jLabel9))
                );
        
        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    private void MorpionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MorpionActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_MorpionActionPerformed
    
    private void HumVsIAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_HumVsIAActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_HumVsIAActionPerformed
    
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton2ActionPerformed
    
    private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MouseClicked
        System.exit(0);
    }//GEN-LAST:event_jButton2MouseClicked
    
    private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
        int a = Tool.monRandom(56,100);
        int b = Tool.monRandom(1,55);
        if(this.Morpion.isSelected()) {
            if(this.IAvsIA.isSelected()){
                Joueur J1 = new JoueurAleatoireMorpion(a,this.Nom1.getText());
                Joueur J2 = new JoueurAleatoireMorpion(b,this.Nom2.getText());
                Jeu j = new JeuDeMorpion(J1,J2);
                FenetrePrincipale f = new FenetrePrincipale(j);
                f.champ1.setText(this.Nom1.getText());
                f.champ2.setText(this.Nom2.getText());
                f.bouton2.setEnabled(false);
                f.nouveau.setEnabled(false);
                //                Thread p = new Thread (j);
                //                p.start();
                this.dispose();
                
            }
            if (this.HumVsIA.isSelected()){
                Joueur J1 = new JoueurHumainMorpion(a,this.Nom1.getText());
                Joueur J2 = new JoueurAleatoireMorpion(b,this.Nom2.getText());
                Jeu j = new JeuDeMorpion(J1,J2);
                FenetrePrincipale f = new FenetrePrincipale(j);
                f.champ1.setText(this.Nom1.getText());
                f.champ2.setText(this.Nom2.getText());
                f.bouton2.setEnabled(false);
                f.nouveau.setEnabled(false);
                //                Thread p = new Thread (j);
                //                p.start();
                this.dispose();
                
            }
            if (this.HumVsHum.isSelected()){
                Joueur J1 = new JoueurHumainMorpion(a,this.Nom1.getText());
                Joueur J2 = new JoueurHumainMorpion(b,this.Nom2.getText());
                Jeu j = new JeuDeMorpion(J1,J2);
                FenetrePrincipale f = new FenetrePrincipale(j);
                f.champ1.setText(this.Nom1.getText());
                f.champ2.setText(this.Nom2.getText());
                f.bouton2.setEnabled(false);
                f.nouveau.setEnabled(false);
                f.niveauCPU.setEnabled(false);
                //                Thread p = new Thread (j);
                //                p.start();
                this.dispose();
                
            }
            
        }
        if(this.Puissance4.isSelected()) {
            if(this.IAvsIA.isSelected()){
                Joueur J1 = new JoueurAleatoirePuissance4(a,this.Nom1.getText());
                Joueur J2 = new JoueurAleatoirePuissance4(b,this.Nom2.getText());
                Jeu j = new JeuDePuissance4(J1,J2);
                FenetrePrincipale f = new FenetrePrincipale(j);
                f.champ1.setText(this.Nom1.getText());
                f.champ2.setText(this.Nom2.getText());
                f.bouton2.setEnabled(false);
                f.nouveau.setEnabled(false);
                f.niveauCPU.setEnabled(false);
                //                Thread p = new Thread (j);
                //                p.start();
                this.dispose();
            }
            if (this.HumVsIA.isSelected()){
                Joueur J1 = new JoueurHumainPuissance4(a,this.Nom1.getText());
                Joueur J2 = new JoueurAleatoirePuissance4(b,this.Nom2.getText());
                Jeu j = new JeuDePuissance4(J1,J2);
                FenetrePrincipale f = new FenetrePrincipale(j);
                f.champ1.setText(this.Nom1.getText());
                f.champ2.setText(this.Nom2.getText());
                f.bouton2.setEnabled(false);
                f.nouveau.setEnabled(false);
                f.niveauCPU.setEnabled(false);
                //                Thread p = new Thread (j);
                //                p.start();
                this.dispose();
            }
            if (this.HumVsHum.isSelected()){
                Joueur J1 = new JoueurHumainPuissance4(a,this.Nom1.getText());
                Joueur J2 = new JoueurHumainPuissance4(b,this.Nom2.getText());
                Jeu j = new JeuDePuissance4(J1,J2);
                FenetrePrincipale f = new FenetrePrincipale(j);
                f.champ1.setText(this.Nom1.getText());
                f.champ2.setText(this.Nom2.getText());
                f.bouton2.setEnabled(false);
                f.nouveau.setEnabled(false);
                f.niveauCPU.setEnabled(false);
                //                Thread p = new Thread (j);
                //                p.start();
                this.dispose();
            }
        }
    }//GEN-LAST:event_jButton1MouseClicked
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup ButtonTypeJeu;
    private javax.swing.ButtonGroup ButtonTypeJoueurs;
    private javax.swing.JRadioButton HumVsHum;
    private javax.swing.JRadioButton HumVsIA;
    private javax.swing.JRadioButton IAvsIA;
    private javax.swing.JRadioButton Morpion;
    private javax.swing.JTextField Nom1;
    private javax.swing.JTextField Nom2;
    private javax.swing.JRadioButton Puissance4;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JSeparator jSeparator5;
    // End of variables declaration//GEN-END:variables
}
